/**
 * jims
 */
package com.jims.master.modules.csm.dao;

import com.jims.master.common.persistence.CrudDao;
import com.jims.master.common.persistence.annotation.MyBatisDao;
import com.jims.master.common.web.impl.BaseDto;
import com.jims.master.modules.csm.entity.ExpStock;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 消耗品库存管理DAO接口
 * @author zhuq
 * @version 2017-03-10
 */
@MyBatisDao
public interface ExpStockDao extends CrudDao<ExpStock> {

    /**
     * 更新消耗品库存
     * @param expStock
     * @return
     * @author fengyg
     * @date
     */
    public int updateStockQuantity(ExpStock expStock);

    /**
     * 查询库存
     * @param expStock
     * @return
     * @author fengyg
     */
    public List<ExpStock> getList(ExpStock expStock);

    /**
     * 根据消耗品code,批号，所在库房,orgId获取是否存在该批次消耗品
     * @return
     * @author  zhuq
     */
    public List<ExpStock> findByBatchNo(ExpStock expStock);

    /**
     * 库存量查询
     * @param expStock
     * @return
     */
    public List<ExpStock> findExpList(ExpStock expStock);

    /**
     * 消耗品信息查询
     * @param expStock
     * @return
     */
    public ExpStock findExpByInfoId(ExpStock expStock);
    /**
     * 合并批号库存量查询
     * @param expStock
     * @return
     */
    public List<ExpStock> findExpListbat(ExpStock expStock);

    /**
     * 过期消耗品查找
     * @param expStock
     * @return
     */
    public List<ExpStock> findExpStock(ExpStock expStock);

    /**
     * 盘点消耗品列表
     * @param expStock
     * @return
     */
    public List<ExpStock> findInventoryStock(ExpStock expStock);

    /**
     * 根据待发消耗处方主表的Id组装成待发消耗库存表list
     * @param applyId
     * @return
     * @ZhuQ
     */
    public List<ExpStock> findByApplyId(@Param("applyId") String applyId);

    /**
     * 根据库房id,expInfo，orgId查询库存量的和
     * @param expStock
     * @return
     * @ZhuQ
     */
    public List<ExpStock> findByQuantity(ExpStock expStock);

    /**
     * 根据根据expInfo,storageId,orgId查询所有未过期的库存list
     * @param expStock
     * @return
     * @ZhuQ
     */
    public List<ExpStock> findByExpireDate(ExpStock expStock);

    /**
     * 根据根据expInfo,storageId,orgId查询所有库存大于0的list
     * @param expStock
     * @return
     * @ZhuQ
     */
    public List<ExpStock> findByInfoId(ExpStock expStock);

    /**
     * 根据infoId和库存量查询库存信息
     * @param expStock
     * @return
     * @author fengyg
     */
    public ExpStock findByInfoIdQuantity(ExpStock expStock);

    /**
     * 根据待patientId/clinicId获取待发放的消耗品list
     * @return
     * @ZhuQ
     */
    public List<ExpStock> expListOut(@Param("patientId") String patientId, @Param("clinicId") String clinicId,@Param("storageId") String storageId);

    /**
     * 根据待patientId/clinicId获取已发放的消耗品list
     * @return
     * @ZhuQ
     */
    public List<ExpStock> expListGiveOut(@Param("patientId") String patientId, @Param("clinicId") String clinicId,@Param("storageId") String storageId);


    /**
     * 根据待patientId/clinicId包装规格获取实际上要发的小包装消耗品list
     * @return
     * @ZhuQ
     */
    public List<ExpStock> expListOutBySpec(@Param("patientId") String patientId, @Param("clinicId") String clinicId,@Param("storageId") String storageId);

    /**
     * 根据待treatId获取要退的消耗品数量list
     * @return
     * @ZhuQ
     */
    public List<ExpStock> expListInBySpec(@Param("treatId") String treatId);


    /**
     * 科室申领物品,库存数大于0的物品自动补全
     * @param q
     * @param limit
     * @param orgId
     * @param storageId
     * @return
     * @author fengyg
     * @date 2017-06-16
     */
    public List<ExpStock> autoCompleteStockList(@Param("q")String q,@Param("limit")String limit,@Param("orgId")String orgId,@Param("storageId")String storageId);


    /**
     * 消耗品自动补全
     * @param orgId  机构id
     * @param q  输入码
     * @param limit
     * @return
     * @author zhangyao
     * @date 2017-07-19
     */
    public List<BaseDto> automatic(@Param("orgId") String orgId,@Param("q")String q,@Param("limit")String limit,@Param("storageCode")String storageCode);



}